package com.fourth.service.impl;

import com.fourth.dao.UbBusinessInfoDao;
import com.fourth.dao.UbStockDao;
import com.fourth.service.UbBusinessInfoService;
import com.fourth.service.UbStockService;
import com.ljx.entity.BusinessInfo;
import com.ljx.entity.Stock;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author Mr.ma
 * @since 2023/3/9 10:44
 **/
@Service
public class UbBusinessInfoServiceImpl implements UbBusinessInfoService {
    @Resource
    private UbBusinessInfoDao ubBusinessInfoDao;


    @Override
    public BusinessInfo selectByBid(String bid) {
        BusinessInfo businessInfo = ubBusinessInfoDao.selectByBid(bid);
        return businessInfo;
    }

    @Override
    public int changeMoney(String bid, BigDecimal payMoney) {
        BusinessInfo businessInfo = ubBusinessInfoDao.selectByBid(bid);
        Double money = businessInfo.getMoney();
        BigDecimal bigDecimal = BigDecimal.valueOf(money);
        BigDecimal add = bigDecimal.add(payMoney);
        Double totalMoney = add.doubleValue();
        int i = ubBusinessInfoDao.changeMoney(bid, totalMoney);
        return i;
    }
}
